package com.travel.model.entity.payment;

import com.travel.model.entity.auth.User;
import com.travel.model.entity.service.Service;
import com.travel.model.enums.OrderStatus;
import com.travel.model.enums.PaymentMethod;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "orders")
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "Order entity")
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "Order ID", example = "1")
    private Long id;

    @Schema(description = "Order number", example = "ORD20240312001")
    @Column(unique = true)
    private String orderNumber;

    @ManyToOne
    @JoinColumn(name = "user_id")
    @Schema(description = "User who placed the order")
    private User user;

    @ManyToOne
    @JoinColumn(name = "service_id")
    @Schema(description = "Service being ordered")
    private Service service;

    @Schema(description = "Order amount", example = "299.99")
    private BigDecimal amount;

    @Schema(description = "Order status", example = "PENDING")
    @Enumerated(EnumType.STRING)
    private OrderStatus orderStatus;

    @Schema(description = "Payment method", example = "ALIPAY")
    @Enumerated(EnumType.STRING)
    private PaymentMethod paymentMethod;

    @Schema(description = "Order creation time")
    @CreatedDate
    private LocalDateTime orderTime;

    @Schema(description = "Last update time")
    @LastModifiedDate
    private LocalDateTime updateTime;

    @Schema(description = "Special requirements", example = "Need vegetarian food")
    private String remarks;

    @Schema(description = "Record status (1: active, 0: deleted)", example = "1")
    private Integer status = 1;
} 